import java.util.*;

public class testHeap {
    public static void main(String[] args) {
        comparator cmp=new comparator();
        Student s1=new Student(1332);
        Student s2=new Student(12425);
        Student s3=new Student(2449);
        Student s4=new Student(1456);
        Student s5=new Student(787);
        Student s6=new Student(457);
        Student s7=new Student(5436);
        Student s8=new Student(11524);
        PriorityQueue<Student> heap=new PriorityQueue<Student>(cmp);
        heap.add(s1);
        heap.add(s2);
        heap.add(s3);
        heap.add(s4);
        heap.add(s5);
        heap.add(s6);
        heap.add(s7);
        heap.add(s8);
        while(heap.size()>0)
        {
            System.out.println(heap.peek());
            heap.poll();
        }
    }
}

class Student {
    public int age;

    public Student(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                '}';
    }
}

class comparator implements Comparator<Student>{
   public int compare(Student o1,Student o2){
       return o2.age-o1.age;
   }
}
